package com.project.thread;

import com.project.bean.OrderBean;
import com.project.service.IOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * Created by 卢泓佚  414814103@qq.com on 2021/10/13
 */
public class OrderThread implements Runnable{
    private IOrderService orderService;
    private String orderCode;
    private int minute;
    public OrderThread(IOrderService orderService,String orderCode,int minute){
        this.orderService=orderService;
        this.orderCode = orderCode;
        this.minute =minute;
    }

    @Override
    public void run() {
        try {
            Thread.sleep(60000L *minute);
           OrderBean orderBean =  orderService.findByOrderCode(orderCode);
           if (orderBean.getStatus()!=3){
               orderService.updateOrderStatus(orderCode,4);
           }
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
